from django.db import models
from django.utils import timezone


# Create your models here.


class Base(models.Model):
    # 创建时间
    create_time = models.DateTimeField(default=timezone.now, null=True)

    class Meta:
        abstract = True


# 用户类
class User(Base):
    username = models.CharField(max_length=100, unique=True)
    password = models.CharField(max_length=200)
    phone = models.CharField(max_length=100, unique=True, null=True)
    level = models.IntegerField(default=1)
    sf = models.BooleanField(default=False)
    sf_type = models.CharField(max_length=20, verbose_name="三方类型", null=True)
    sf_id = models.IntegerField(null=True)

    class Meta:
        db_table = "user"


class NodeModel(models.Model):
    node_name = models.CharField(max_length=200)

    class Meta:
        db_table = 'Node'


class AccessMoedl(models.Model):
    user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
    node = models.ForeignKey(NodeModel, on_delete=models.SET_NULL, null=True)

    class Meta:
        db_table = 'Access'


class Identity(models.Model):
    level = models.IntegerField(primary_key=True, unique=True, null=False, verbose_name='身份等级')
    name = models.CharField(max_length=150, verbose_name='身份等级名')

    def __str__(self):
        return self.name


class User_Identity(models.Model):
    user = models.ForeignKey(to=User, on_delete=models.CASCADE)
    identity = models.ForeignKey(to=Identity, on_delete=models.CASCADE)


class Gongdan(models.Model):
    name = models.CharField(max_length=200)
    pid = models.IntegerField(default=0)

    def __str__(self):
        return self.name


import mongoengine


class QinjiaMoban(models.Model):
    uid = models.IntegerField()
    pid = models.CharField(null=True,max_length=20)
    Approved_list = models.CharField(max_length=150)
    start = models.IntegerField(default=0)
    refuse = models.CharField(max_length=100,null=True,default=None)
    info = models.CharField(max_length=300)
    qiniuimg = models.CharField(max_length=100,null=True)
    youpaiimg = models.CharField(max_length=100,null=True)


class Moban(mongoengine.Document):
    pid = mongoengine.IntField(max_length=100)
    geshi = mongoengine.StringField(max_length=500)

class Qingjia_gl(models.Model):
    pid = models.IntegerField(verbose_name='审批人id')
    gid = models.IntegerField(verbose_name='请假单id')



